home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWFiles / SLFileSy.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  8.9 KB  |  352 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                SLFileSy.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef SLFILESY_H
  11. #define SLFILESY_H
  12.  
  13. #if defined(FW_BUILD_MAC) && !defined(__FILES__)
  14. #include "Files.h"
  15. #endif
  16.  
  17. #if defined(FW_BUILD_MAC) && !defined(__ERRORS__)
  18. #include "Errors.h"
  19. #endif
  20.  
  21. #ifndef SLSTRREP_H
  22. #include "SLStrRep.h"
  23. #endif
  24.  
  25. #ifdef FW_BUILD_WIN16
  26. // WINVER 0x30a
  27. #include <windows.h>
  28. #endif
  29.  
  30. #ifdef FW_BUILD_WIN32
  31. #include <winerror.h>
  32. #include <winbase.h>
  33. #endif
  34.  
  35. // Export or Import functions for CFM-68K [sfu]
  36.  
  37. #if defined(FW_ODFLIB_IMPORT)
  38. #pragma import on
  39. #elif defined(FW_ODFLIB)
  40. #pragma export on
  41. #endif
  42.  
  43. FW_EXTERN_C_BEGIN
  44.  
  45.  
  46. //========================================================================================
  47. //  Forward declarations
  48. //========================================================================================
  49. class FW_OFileSpecification;
  50. class FW_ODirectorySpecification;
  51.  
  52. //========================================================================================
  53. //  Forward declarations
  54. //========================================================================================
  55.  
  56. #ifdef FW_BUILD_WIN16
  57. typedef HFILE FW_PlatformFileHandle;
  58. #endif
  59.  
  60. #ifdef FW_BUILD_WIN32
  61. typedef HANDLE FW_PlatformFileHandle;
  62. #endif
  63.  
  64. #ifdef FW_BUILD_MAC
  65. typedef short FW_PlatformFileHandle;
  66. const OSType FW_kDefaultFileType = 'TEXT';
  67. const OSType FW_kDefaultCreatorType = 'ttxt';
  68. #endif
  69.  
  70. const FW_PlatformFileHandle FW_kInvalidAccessHandle = (FW_PlatformFileHandle)(-1);
  71. const long FW_kInvalidSeek = -1;
  72.  
  73.  
  74. //========================================================================================
  75. //    FW_EAccess and FW_EDeny
  76. //========================================================================================
  77.  
  78. #ifdef FW_BUILD_MAC
  79. enum FW_EAccess
  80. {
  81.     FW_kRead      = fsRdPerm,
  82.     FW_kWrite     = fsWrPerm,
  83.     FW_kReadWrite = fsRdWrPerm
  84. };
  85.  
  86. // Mac defines these constants as bit positions.
  87. enum FW_EDeny
  88. {
  89.     FW_kDenyNone      = 0x00,
  90.     FW_kDenyRead      = 0x10,
  91.     FW_kDenyWrite     = 0x20,
  92.     FW_kDenyReadWrite = 0x30
  93. };
  94. #endif
  95.  
  96.  
  97. #ifdef FW_BUILD_WIN16
  98. enum FW_EAccess
  99. {
  100.     FW_kRead      = OF_READ,
  101.     FW_kWrite     = OF_WRITE,
  102.     FW_kReadWrite = OF_READWRITE
  103. };
  104.  
  105.  
  106. enum FW_EDeny
  107. {
  108.     FW_kDenyNone      = OF_SHARE_DENY_NONE,
  109.     FW_kDenyRead      = OF_SHARE_DENY_READ,
  110.     FW_kDenyWrite     = OF_SHARE_DENY_WRITE,
  111.     FW_kDenyReadWrite = OF_SHARE_EXCLUSIVE
  112. };
  113. #endif
  114.  
  115.  
  116. #ifdef FW_BUILD_WIN32
  117. enum FW_EAccess
  118. {
  119.     FW_kRead      = GENERIC_READ,
  120.     FW_kWrite     = GENERIC_WRITE,
  121.     FW_kReadWrite = GENERIC_READ | GENERIC_WRITE
  122. };
  123.  
  124.  
  125. enum FW_EDeny
  126. {
  127.     FW_kDenyNone      = FILE_SHARE_READ | FILE_SHARE_WRITE,
  128.     FW_kDenyRead      = FILE_SHARE_WRITE,
  129.     FW_kDenyWrite     = FILE_SHARE_READ,
  130.     FW_kDenyReadWrite = 0
  131. };
  132. #endif
  133.  
  134.  
  135. //========================================================================================
  136. //    FW_SAccessPermission
  137. //
  138. //    "C" class defining the structure of access permissions
  139. //========================================================================================
  140.  
  141. struct FW_SAccessPermission
  142. {
  143.     unsigned long fAccess;
  144.     unsigned long fDeny;
  145. };
  146.  
  147. //========================================================================================
  148. //    FW_PrivFileSystem
  149. //
  150. //    Common file operations, private version.  The error values, if any, are returned via 
  151. //    the Environment variable.  
  152. //========================================================================================
  153.  
  154. void                        SL_API
  155. FW_PrivFileSystem_CreateFile(Environment* ev, FW_OFileSpecification* fileSpec, FW_Boolean overWriteExisting = FALSE);
  156.     // Creates the file specified by fileSpec.  If the file already exists and 
  157.     //   overWriteExisting is TRUE, then the file will be truncated to zero-length.
  158.     //   Otherwise, the file will be left alone.
  159.  
  160. void                        SL_API
  161. FW_PrivFileSystem_DeleteFile(Environment* ev, FW_OFileSpecification* fileSpec);
  162.     // Deletes the file specified by fileSpec.  WARNING: This action cannot be undone.
  163.  
  164. void                        SL_API
  165. FW_PrivFileSystem_CreateDirectory(Environment* ev, FW_ODirectorySpecification* directory);
  166.     // Creates the directory specified by directory.  If the directory already
  167.     //   exists, then nothing is done.  
  168.     
  169. void                        SL_API
  170. FW_PrivFileSystem_DeleteDirectory(Environment* ev, FW_ODirectorySpecification* directory);
  171.     // Deletes the directory specified by directory.  This routine will only 
  172.     //   delete an empty directory.  The user must make sure that there are no
  173.     //   files left in the directory.  The directory must also not be the current
  174.     //   working directory for it to be deleted.  Use SetCurrentDirectory to set
  175.     //   another directory if this is the case.
  176.     
  177. void                        SL_API
  178. FW_PrivFileSystem_GetCurrentDirectory(Environment* ev, FW_ODirectorySpecification* directory);
  179.     // Sets directory to point to the current default directory.
  180.  
  181. void                        SL_API
  182. FW_PrivFileSystem_SetCurrentDirectory(Environment* ev, FW_ODirectorySpecification* directory);
  183.     // Set the current working directory.
  184.  
  185. FW_Boolean                    SL_API
  186. FW_PrivFileSystem_IsValidDirectory(Environment* ev, FW_ODirectorySpecification* directory);
  187.     // Returns TRUE if the specified directory exists.
  188.  
  189. FW_Boolean                    SL_API
  190. FW_PrivFileSystem_IsValidDrive(Environment* ev, FW_HString driveName);
  191.     // Returns TRUE if the specified drive exists.
  192.  
  193. FW_Boolean                    SL_API
  194. FW_PrivFileSystem_IsValidFile(Environment* ev, FW_OFileSpecification* theFile);
  195.     // Tests the existence of a file.
  196.  
  197. #ifdef FW_BUILD_WIN
  198. FW_Boolean                    SL_API
  199. FW_PrivFileSystem_WinPathExists(Environment* ev, FW_HString pathName);
  200.     // Tests the existence of a particular path and/or filename.  Paths should NOT
  201.     //   be terminated with a path delimiter.
  202. #endif
  203.  
  204. #ifdef FW_BUILD_MAC
  205. FW_Boolean                    SL_API
  206. FW_PrivFileSystem_MacIsVolumeShared(Environment* ev, short volumeRefNum);
  207.         // Returns TRUE if the volume specified by volumeRefNum 
  208. #endif
  209.  
  210.  
  211. //========================================================================================
  212. //    FW_FileSystem
  213. //
  214. //    Common file operations, public version.  These routines call the private versions and
  215. //    throw on error.
  216. //========================================================================================
  217.  
  218. inline void
  219. FW_FileSystem_CreateFile(Environment* ev, FW_OFileSpecification* fileSpec, FW_Boolean overWriteExisting = FALSE)
  220. {
  221.     FW_PrivFileSystem_CreateFile(ev, fileSpec, overWriteExisting);
  222.     FW_FailOnEvError(ev);
  223. }
  224.  
  225. inline void
  226. FW_FileSystem_DeleteFile(Environment* ev, FW_OFileSpecification* fileSpec)
  227. {
  228.     FW_PrivFileSystem_DeleteFile(ev, fileSpec);
  229.     FW_FailOnEvError(ev);
  230. }
  231.  
  232. inline void
  233. FW_FileSystem_CreateDirectory(Environment* ev, FW_ODirectorySpecification* directory)
  234. {
  235.     FW_PrivFileSystem_CreateDirectory(ev, directory);
  236.     FW_FailOnEvError(ev);
  237. }
  238.     
  239. inline void
  240. FW_FileSystem_DeleteDirectory(Environment* ev, FW_ODirectorySpecification* directory)
  241. {
  242.     FW_PrivFileSystem_DeleteDirectory(ev, directory);
  243.     FW_FailOnEvError(ev);
  244. }
  245.     
  246. inline void
  247. FW_FileSystem_GetCurrentDirectory(Environment* ev, FW_ODirectorySpecification* directory)
  248. {
  249.     FW_PrivFileSystem_GetCurrentDirectory(ev, directory);
  250.     FW_FailOnEvError(ev);
  251. }
  252.  
  253. inline void
  254. FW_FileSystem_SetCurrentDirectory(Environment* ev, FW_ODirectorySpecification* directory)
  255. {
  256.     FW_PrivFileSystem_SetCurrentDirectory(ev, directory);
  257.     FW_FailOnEvError(ev);
  258. }
  259.  
  260. inline FW_Boolean
  261. FW_FileSystem_IsValidDirectory(Environment* ev, FW_ODirectorySpecification* directory)
  262. {
  263.  
  264.     FW_Boolean result = FW_PrivFileSystem_IsValidDirectory(ev, directory);
  265.     FW_FailOnEvError(ev);
  266.     return result;
  267. }
  268.  
  269. inline FW_Boolean
  270. FW_FileSystem_IsValidDrive(Environment* ev, FW_HString driveName)
  271. {
  272.  
  273.     FW_Boolean result = FW_PrivFileSystem_IsValidDrive(ev, driveName);
  274.     FW_FailOnEvError(ev);
  275.     return result;
  276. }
  277.  
  278. inline FW_Boolean
  279. FW_FileSystem_IsValidFile(Environment* ev, FW_OFileSpecification* theFile)
  280. {
  281.  
  282.     FW_Boolean result = FW_PrivFileSystem_IsValidFile(ev, theFile);
  283.     FW_FailOnEvError(ev);
  284.     return result;
  285. }
  286.  
  287. #ifdef FW_BUILD_WIN
  288. inline FW_Boolean
  289. FW_FileSystem_WinPathExists(Environment* ev, FW_HString pathName)
  290. {
  291.     FW_Boolean result = FW_PrivFileSystem_WinPathExists(ev, pathName);
  292.     FW_FailOnEvError(ev);
  293.     return result;
  294. }
  295. #endif
  296.  
  297. #ifdef FW_BUILD_MAC
  298. inline FW_Boolean
  299. FW_FileSystem_MacIsVolumeShared(Environment* ev, short volumeRefNum)
  300. {
  301.  
  302.     FW_Boolean result = FW_PrivFileSystem_MacIsVolumeShared(ev, volumeRefNum);
  303.     FW_FailOnEvError(ev);
  304.     return result;
  305. }
  306. #endif
  307.  
  308.  
  309.  
  310.  
  311. #ifdef FW_BUILD_WIN16
  312. enum FW_EFS_MoveMethods
  313. {
  314.     FW_kFromStart   = 0,
  315.     FW_kFromCurrent = 1,
  316.     FW_kFromEnd     = 2
  317. };
  318. #endif
  319.  
  320. #ifdef FW_BUILD_WIN32
  321. enum FW_EFS_MoveMethods
  322. {
  323.     FW_kFromStart   = FILE_BEGIN,
  324.     FW_kFromCurrent = FILE_CURRENT,
  325.     FW_kFromEnd     = FILE_END
  326. };
  327. #endif
  328.  
  329.  
  330. #ifdef FW_BUILD_MAC
  331. enum FW_EFS_MoveMethods
  332. {
  333.     FW_kFromStart = fsFromStart,
  334.     FW_kFromCurrent = fsFromMark,
  335.     FW_kFromEnd = fsFromLEOF
  336. };
  337. #endif
  338.  
  339. FW_EXTERN_C_END
  340.  
  341. // For CFM-68K [sfu]
  342.  
  343. #if defined(FW_ODFLIB_IMPORT)
  344. #pragma import off
  345. #elif defined(FW_ODFLIB)
  346. #pragma export off
  347. #endif
  348.  
  349. #endif
  350.  
  351.  
  352.